#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sched.h>
#include <sys/mman.h>
#include "realtime.h"
int init_realtime(void)
{
    printf("Init realtime environment\n");

    if (geteuid() == 0) {
        struct sched_param sp;
        memset(&sp, 0, sizeof(sp));
        sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
        sched_setscheduler(0, SCHED_FIFO, &sp);
        mlockall(MCL_CURRENT | MCL_FUTURE);
        fprintf(stderr, "Running with realtime priority!\n");
    } else {
        fprintf(stderr, "Not running with realtime priority.\n");
    }
    return 0;
}
